package com.xuhf.consumeType.producer;

import com.xuhf.config.Config;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

public class Producer2 {

    public static void main(String[] args) throws Exception {
        DefaultMQProducer producer = new DefaultMQProducer(Config.PRODUCER_GROUP);
        producer.setNamesrvAddr(Config.NAMESRV_ADDR);
        producer.start();
        for (int i = 0; i < 1000; i++) {
            Message message = new Message("02-consume-type", "tagB", (i + " hello, rocketmq from producer2 ").getBytes());
            SendResult sendResult = producer.send(message);
            System.out.println("生产者发送消息：" + sendResult.getMsgId() + "，发送状态：" + sendResult.getSendStatus());
            Thread.sleep(800);
        }

        producer.shutdown();
    }
}
